﻿#include "CMainApplication.h"

#include <QFile>

#include "core/CDeviceManager.h"
#include "core/logger.h"
#include "version.h"
#include "view/CMainWidget.h"
#include "zlbase/zlbase.h"

CMainApplication::CMainApplication(QObject *parent) :
    QObject(parent),
    main_widget_(new CMainWidget)
{
}

CMainApplication::~CMainApplication()
{
    delete main_widget_;
}

int CMainApplication::Run(int argc, char *argv[])
{
    // load style sheet
    QFile file(":/assets/css/default.qss");
    if (file.open(QIODevice::ReadOnly | QFile::Text))
    {
        auto style = file.readAll();
        main_widget_->setStyleSheet(style);
    }

    CDeviceManager::Instance().LoadDeviceConfiguration();
    CDeviceManager::Instance().LoadZLBasePlugins();

    main_widget_->SetUp();
    main_widget_->show();
    return 0;
}
